
/**
 * 用于测试 mongodb
 */

const mongoose = require('mongoose');
const { Schema } = mongoose;

const db = mongoose.createConnection('mongodb://127.0.0.1:27017/hotServer', { useNewUrlParser: true });
db.on('connected', err => {
    if (err) {
        console.error('connect error: ', err);
    }
    else {
        console.log('connect success!');
    }
});

// const test = db.model('test', new Schema({}, { strict: false, versionKey: false }), 'test');
// test.findOne({}).then(val => {
//     console.log('查询结果： ', val);
// });

const test = db.model('test', new Schema({}, { strict: false, versionKey: false }), 'test');
// test.create({ route: '/first', func: `ctx.body = 'hello first';` }).then(rel => console.log(rel));
// test.findOne({}).then(val => {
//     console.log('查询结果： ', val); 
// });

exports = module.exports = {
    test
};